import random


def initialize_array():
    """
    初始化数组
    :return:
    """
    arr: list[int] = [1] * 5
    nums: list[int] = [1, 2, 3, 4, 5, '123']

    for i in range(len(arr)):
        print(arr[i])

    for i in range(len(nums)):
        print(nums[i])


def random_access(nums: list[int]) -> int:
    """
    随机访问
    :param nums:
    :return:
    """
    random_index = random.randint(0, len(nums) - 1)
    return nums[random_index]


def insert_array(nums: list[int], num: int, index: int):
    """
    在数组的索引 index 处插入元素 num
    :param nums: 数组
    :param num: 要插入的元素
    :param index: 数组下标
    :return:
    """
    # 把索引 index 以及之后的所有元素往后移一位
    for i in range(len(nums) - 1, index, -1):
        print(i)
        nums[i] = nums[i - 1]
    # 将 num 赋给 index 处的元素
    nums[index] = num
    print(nums)


if __name__ == '__main__':
    insert_array([1, 2, 3, 4, 5], 6, 0)


